ARD2  1.00 for Rev B. Hardware
Airbag Reference Demonstrator using MPC5604P
SBC_AL.c File Reference

System basis chip abstraction layer for airbag application. Upper layers shouldn't talk directly with the SBC driver to avoid file dependencies in the application. More...

#include "derivative.h"
#include "Compile_Options.h"
#include "HAL.h"
#include "DSPI.h"
#include "MailScheduler.h"
#include "CG147.h"
#include "CG147_Diag.h"
#include "SBC_AL.h"
#include "Utils.h"
#include "MMA51xx.h"
#include "SIU.h"

Functions

uint8_t u8fnSBCPreSchedulerEnableWarningLamp (uint8_t u8Enable)
 This routine shall be called before the scheduler has been launched to turn on the warning lamp connected to the SBC.
uint8_t u8fnSBCEnableWarningLamp (uint8_t u8Enable)
 This routine shall be called after the scheduler has been launched to turn on the warning lamp connected to the SBC.
void vfnSBCPreSchedulerInit (void)
 This routine shall be called before the scheduler has been launched to initialize the SBC.
void vfnSBCResetPin (uint32_t u32State)
 Sets a logical level on the SBC's reset pin.
uint32_t u32fnSBCInit (void)
 This routine shall be called after the scheduler has been launched to initialize the SBC.
uint32_t u32fnSBCPerformInitialTests (void)
 This routine performs initial tests on the SBC at startup to guarantee operation. It includes POM, ADC, Mux, and FLM tests.
uint16_t u16fnSBCGatherPSI5SatelliteData (uint8_t *pu8PSI5Data)
 First, this function instructs the SBC to turn automatic Sync-pulse generation. Next, and according to the PSI5 standard, it captures all satellite initial data, places it into an array, and returns a status indicating if satellites are happy or not.
uint32_t u32fnSBCSchedulePSISat (uint16_t *pu16RawAccelArray)
 Schedules reading from all PSI5 satellites.
uint8_t u8fnSBCSchedulePSync (void)
 Schedules a synchronization pulse for synchronous PSI5 satellites. May not be necessary if the SBC is generating them automatically.
uint8_t u8fnSBCSyncSM (const uint8_t cu8Period)
 Synchronizes the SBC to a given period with the watch-dog 2 as a reference clock. Necessary to guarantee accuracy regarding PSI5 sync pulses.
uint32_t u32fnSBCExtractPSISat (uint16_t *pu16RawAccelArray, uint16_t *pu16Filtered)
 Transforms raw data returned by satellites into usable data.
uint32_t u32fnSBCScheduleCmd (uint8_t u8Cmd, uint8_t u8Arg, uint16_t *pu16Response)
 Schedules a specific command to be sent.
uint32_t u32fnSBCFireSquibs (const uint16_t cu16SquibMask)
 Complete sequence of commands used to fire any number of squibs.
uint32_t u32fnSBCSquibFiringStatus (uint16_t *pu16Response)
 Reads back fire counter for all squibs. If anyone of them surpass a defined threshold (SBC_FIRED_SQUIB_MIN_TIME), they're flagged as "fired.".

Variables

const uint16_t cu16PresentSquibs
const uint16_t cu16PresentSatellites
const uint16_t cu16FiredSquibs
const uint16_t cu16CrashedSatellites
const uint8_t cu8SBCSatelliteData []
const uint8_t cau8SBCSatTestVariableFilter []
uint16_t gu16ActivePSI5Channels
uint16_t gu16ActiveSquibChannels
uint16_t gu16FiredSquibs
uint16_t gu16SquibsToFire
uint16_t gu16CrashedSatellites
uint16_t gu16ConfirmedSatellites
uint32_t gu32SBCTime
uint8_t gu8SBCSatelliteData [SBC_N_SATELLITES_POSSIBLE *MMA5100_N_REGISTERS]

Detailed Description

System basis chip abstraction layer for airbag application. Upper layers shouldn't talk directly with the SBC driver to avoid file dependencies in the application.

Copyright (c) 2011 Freescale Semiconductor Freescale Confidential Proprietary

Author:
Freescale Semiconductor
SASD Automotive
R11515
R54967
Version:
Date:
Warning:
(If needed)

History:


Function Documentation

uint16_t u16fnSBCGatherPSI5SatelliteData ( uint8_t *  pu8PSI5Data)

First, this function instructs the SBC to turn automatic Sync-pulse generation. Next, and according to the PSI5 standard, it captures all satellite initial data, places it into an array, and returns a status indicating if satellites are happy or not.

Parameters:
pu8PSI5Data,:Pointer to an array where all satellites settings shall be stored. Each satellite requires n bytes, as defined in the MMA5100_REGISTER_INDEX within the MMA51xx interpreter file.
Returns:
u16Status: A combination of MMA5100_COMMAND_NOT_RECOGNIZED, MMA5100_SENSOR_BUSY_STATUS, MMA5100_SENSOR_DEFECT_STATUS, MMA5100_SENSOR_READY_UNLOCKED_STATUS, and/or MMA5100_SENSOR_READY_STATUS.
Note:
Current implementation assumes only MMA51xx satellites.
uint32_t u32fnSBCExtractPSISat ( uint16_t *  pu16RawAccelArray,
uint16_t *  pu16Filtered 
)

Transforms raw data returned by satellites into usable data.

Parameters:
pu16RawAccelArray,:pointer to where raw data is stored.
pu16Filtered,:Array of filtered data.
Returns:
CLEAR if all acceleration results were extracted correctly and their corresponding status was clear (refer to u8fnCG147ExtractPSIAccel); or a flag set for each channel that was not clear, from CG147_SAT_MASK_MIN to CG147_SAT_MASK_MAX.
uint32_t u32fnSBCFireSquibs ( const uint16_t  cu16SquibMask)

Complete sequence of commands used to fire any number of squibs.

Parameters:
cu16SquibMask,:Mask used to determine which squibs will be fired, justified right, following positive logic.
Returns:
u32Status: Clear if all ok; STATUS_SCHEDULER_PROBLEM if a problem was found writing to the device.
uint32_t u32fnSBCInit ( void  )

This routine shall be called after the scheduler has been launched to initialize the SBC.

Parameters:
None.
Returns:
u32Status: Clear if all ok, SBC_TEST_SCHEDULER_FAILED if a scheduler problem has been found, SBC_TEST_UNEXPECTED_SPI_RESULT if initial 16-bit configuration has not been performed successfully, SBC_TEST_ALL_SAT if satellites fail to initialize correctly, a mask for each satellite that has not been found according to cu16PresentSatellites (from BIT0 to BIT11), SBC_TEST_SBC_FAILED if any SBC test has failed.
uint32_t u32fnSBCPerformInitialTests ( void  )

This routine performs initial tests on the SBC at startup to guarantee operation. It includes POM, ADC, Mux, and FLM tests.

Parameters:
None.
Returns:
Zero if no problems; otherwise MAILBOX_IS_BEING_WRITTEN, or MAILBOX_CAPACITY_HAS_BEEN_REACHED; SBC_TEST_SCHEDULER_FAILED if there was a problem reading back from the scheduler; SBC_TEST_SBC_ADC_FAILED if the given test instance has failed; SBC_TEST_FLM_LEAK_FAILED if the selected test was high-leakage related and it was failed; SBC_TEST_FLM_LOWLEAK_FAILED if the selected test was low-leakage related and it was failed; SBC_TEST_FLM_RESISTANCE_FAILED if the resistance was outside the pre-established limits. All failed status words will contain a flag corresponding to the failed squibs; SBC_TEST_SBC_FAILED if ADC or MUX, or ERx tests are failed;
uint32_t u32fnSBCScheduleCmd ( uint8_t  u8Cmd,
uint8_t  u8Arg,
uint16_t *  pu16Response 
)

Schedules a specific command to be sent.

Parameters:
u8Cmd,:Command
u8Arg,:Argument to the command
pu16Response,:Pointer to array where the response shall be saved
Returns:
u32Status: Clear if all ok; STATUS_SCHEDULER_PROBLEM if a problem was found writing to the device.
uint32_t u32fnSBCSchedulePSISat ( uint16_t *  pu16RawAccelArray)

Schedules reading from all PSI5 satellites.

Parameters:
pu16RawAccelArray,:pointer to where raw data will be stored.
Returns:
u32Status: Clear if all ok, STATUS_SCHEDULER_PROBLEM if there has been a problem with the schedule.
uint32_t u32fnSBCSquibFiringStatus ( uint16_t *  pu16Response)

Reads back fire counter for all squibs. If anyone of them surpass a defined threshold (SBC_FIRED_SQUIB_MIN_TIME), they're flagged as "fired.".

Parameters:
pu16Response,:pointer to where the flags will be set. BIT0 to BIT11 are used as flags that are set in case the associated squib has been fired.
Returns:
u32Status: Clear if all ok, STATUS_SCHEDULER_PROBLEM if there has been an issue sending or decoding data to and from the SBC; STATUS_DATA_TRANSFER_ERROR if there has been an error in the response and it is deemed unreliable;
uint8_t u8fnSBCEnableWarningLamp ( uint8_t  u8Enable)

This routine shall be called after the scheduler has been launched to turn on the warning lamp connected to the SBC.

Parameters:
u8Enable,:If zero, disable, otherwise enable.
Returns:
Zero if no problems, otherwise MAILBOX_IS_BEING_WRITTEN, or MAILBOX_CAPACITY_HAS_BEEN_REACHED
uint8_t u8fnSBCPreSchedulerEnableWarningLamp ( uint8_t  u8Enable)

This routine shall be called before the scheduler has been launched to turn on the warning lamp connected to the SBC.

Parameters:
u8Enable,:If zero, disable, otherwise enable.
Returns:
u8Status: Zero if no problems found; 1 if the HW is busy and cannot transmit existing data.
uint8_t u8fnSBCSchedulePSync ( void  )

Schedules a synchronization pulse for synchronous PSI5 satellites. May not be necessary if the SBC is generating them automatically.

Parameters:
None
Returns:
Zero if no problems, otherwise MAILBOX_IS_BEING_WRITTEN, or MAILBOX_CAPACITY_HAS_BEEN_REACHED
uint8_t u8fnSBCSyncSM ( const uint8_t  u8Period)

Synchronizes the SBC to a given period with the watch-dog 2 as a reference clock. Necessary to guarantee accuracy regarding PSI5 sync pulses.

Parameters:
u8Period,:number of scheduler periods to wait after the watch-dog has been sent to SBC.
Returns:
Always CLEAR.
void vfnSBCPreSchedulerInit ( void  )

This routine shall be called before the scheduler has been launched to initialize the SBC.

Parameters:
None.
Returns:
Void.
void vfnSBCResetPin ( uint32_t  u32State)

Sets a logical level on the SBC's reset pin.

Parameters:
u32State,:TRUE if the pin shall hold a high logical level; CLEAR otherwise.
Returns:
Void.

Variable Documentation

Initial value:
{
  TRUE,
  TRUE,
  CLEAR,
  TRUE,
  CLEAR,
  CLEAR,
  CLEAR,
  CLEAR,
  CLEAR,
  CLEAR,
  CLEAR,
  CLEAR,
  CLEAR,
  CLEAR,
  CLEAR,
  CLEAR,
  CLEAR,
  CLEAR,
  CLEAR, }

Following array is used to determine if we test that particular value against the reference or not.

const uint16_t cu16CrashedSatellites
Initial value:
 (SAT_CH0_SLOT0_NOT_CRASHED
    | SAT_CH0_SLOT1_NOT_CRASHED | SAT_CH0_SLOT2_NOT_CRASHED
    | SAT_CH1_SLOT0_NOT_CRASHED | SAT_CH1_SLOT1_NOT_CRASHED
    | SAT_CH1_SLOT2_NOT_CRASHED | SAT_CH2_SLOT0_NOT_CRASHED
    | SAT_CH2_SLOT1_NOT_CRASHED | SAT_CH2_SLOT2_NOT_CRASHED
    | SAT_CH3_SLOT0_NOT_CRASHED | SAT_CH3_SLOT1_NOT_CRASHED
    | SAT_CH3_SLOT2_NOT_CRASHED)

List of all crashed satellites

const uint16_t cu16FiredSquibs
Initial value:
 (SQUIB_CH0_NOT_FIRED | SQUIB_CH0_NOT_FIRED
    | SQUIB_CH1_NOT_FIRED | SQUIB_CH2_NOT_FIRED | SQUIB_CH3_NOT_FIRED
    | SQUIB_CH4_NOT_FIRED | SQUIB_CH5_NOT_FIRED | SQUIB_CH6_NOT_FIRED
    | SQUIB_CH7_NOT_FIRED | SQUIB_CH8_NOT_FIRED | SQUIB_CH9_NOT_FIRED
    | SQUIB_CH10_NOT_FIRED | SQUIB_CH11_NOT_FIRED)

Lists all of the fired squibs

const uint16_t cu16PresentSatellites
Initial value:
 (SAT_CH0_SLOT0_PRESENT | 
    SAT_CH0_SLOT1_ABSENT | 
    SAT_CH0_SLOT2_ABSENT | 
    SAT_CH1_SLOT0_PRESENT | 
    SAT_CH1_SLOT1_ABSENT | 
    SAT_CH1_SLOT2_ABSENT | 
    SAT_CH2_SLOT0_PRESENT | 
    SAT_CH2_SLOT1_ABSENT | 
    SAT_CH2_SLOT2_ABSENT | 
    SAT_CH3_SLOT0_PRESENT | 
    SAT_CH3_SLOT1_ABSENT | 
    SAT_CH3_SLOT2_ABSENT 
)

Lists in order whether a satellite should be active in the system or not

const uint16_t cu16PresentSquibs
Initial value:
 (SQUIB_CH0_PRESENT | 
    SQUIB_CH1_PRESENT | 
    SQUIB_CH2_ABSENT | 
    SQUIB_CH3_PRESENT | 
    SQUIB_CH4_PRESENT | 
    SQUIB_CH5_ABSENT | 
    SQUIB_CH6_PRESENT | 
    SQUIB_CH7_ABSENT | 
    SQUIB_CH8_ABSENT | 
    SQUIB_CH9_PRESENT | 
    SQUIB_CH10_ABSENT | 
    SQUIB_CH11_ABSENT)

Lists in order whether a squib should be active in the system or not

const uint8_t cu8SBCSatelliteData[]

Satellite Data default values

Global variable that keeps in mind which are the active PSI5 channels

Global variable that keeps in mind which are the active squibs

Global that keeps track of satellites that have been confirmed crashed

Global that keeps track of satellites that have been crashed

uint16_t gu16FiredSquibs

Global variable that keeps track of fired squibs

uint16_t gu16SquibsToFire

Global variable that keeps track of squibs to be fired

uint32_t gu32SBCTime

Global variable that remembers last tick value for last SBC-based fn.